<template>
  <div>
    <el-container>
      <el-header>
        Play With Code
        <el-col :span="1">
          {{user.username}}
        </el-col>
      </el-header>
      <el-container>
        <el-aside>
          <el-menu router="true" >
            <el-menu-item index="Home">全部游戏</el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
        <el-footer>
          Copyright @BUAA MSC 2020
        </el-footer>
      
    </el-container>
  </div>
</template>

<style>
  .el-header{
    background-color: #B3C0D1;
    color: rgb(34, 34, 34);
    text-align: center;
    font-size: 20px;
    line-height: 60px;
    font-weight: 200;
  }

  .el-footer{
    background-color: #4a76b1;
    color: rgb(255, 255, 255);
    text-align: center;
    line-height: 60px;
  }

  .el-aside{
    width: 250px;
  }

  .el-main{
    line-height: 60px;
    text-align: center;
    width: 800px;
  }


</style>

<script>
  export default {
    name: "Main",
    data() {
      return {
        user: {
          username: "",
          id:localStorage.getItem("userID")
        },
        aa:"hihi"
      }
    },
    mounted() {
      let _this = this
      let id = this.user.id
      console.log("id = ",id)
      axios.get("/user/get",{
        params:{id}
      }).then((res)=>{
        res = res.data
        if(res.code == 200){
          _this.user = JSON.parse(res.data)
          _this.$forceUpdate()
        }
      }).catch((err)=>(console.log(err)))
    },
    methods:{

    }
  }
</script>

<style scoped>

</style>